using System;
using System.Collections.Generic;
using System.Text;

using System.Data;
using System.Data.SqlClient;

using NUnit.Framework;
using DataAccessLayer;

namespace Utilities
{
    [TestFixture]
    public class IdGeneratorFixture:ConnectionFixture
    {
        private static readonly string tableName = "Artist";
        [Test]
        public void GeneratorTest()
        {
            SqlCommand selectCmd = new SqlCommand("SELECT nextid FROM PKSequence WHERE tablename=@tablename", Connection);
            selectCmd.Parameters.Add("@tablename", SqlDbType.VarChar).Value = tableName;

            long nextId = (long)selectCmd.ExecuteScalar();
            long generatedId = IdGenerator.GetNextId(tableName, Connection);
            Assert.AreEqual(nextId, generatedId);

            nextId = (long)selectCmd.ExecuteScalar();
            Assert.AreEqual(nextId, generatedId + 1);

        }
    }
}
